package com.example.aop_test.controller;

import com.example.aop_test.mapper.StudentMapper;
import com.example.aop_test.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2023-03-23
 * Time: 10:57
 */
@RestController
public class StudentController {

    @Autowired
    private StudentMapper studentMapper;

    @RequestMapping("/list")
    //查询所有学生列表
    public List<Student> list(){
        List<Student> list = studentMapper.selectList();

        return list;
    }

    @RequestMapping("/add")
    public void add(Student student){
        int a = studentMapper.add(student);
        System.out.println(a);
    }

    @RequestMapping("/uplaod")
    public void modifyById(Student student){
        //根据id修改
        if (student.getStuId() != 0){
            student.setStuName("修改的名字");
        }

        studentMapper.upload(student);

    }

    @RequestMapping("/remove")
    public void removeById(int id){
        studentMapper.remove(id);
    }


}
